
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#include "reflecxx.h"

enum my_enum_t {
    ME_NEGATIVE_ONE = -1,
    ME_TWO = 2,
    ME_ONE_THOUSAND = 1000,
};

typedef enum {
    AME_ZERO,
    AME_ONE,
    AME_TWO,
    AME_THREE,
} also_my_enum_t;

extern struct reflecxx_full_type my_enum_t_type_info;
extern struct reflecxx_full_type also_my_enum_t_type_info;

int main(int argc, char *argv[])
{
    int retval = EXIT_SUCCESS;
    const char *name;

    name = reflecxx_enum_by_value(&my_enum_t_type_info, ME_NEGATIVE_ONE)->
	ree_name;
    assert(strcmp(name, "ME_NEGATIVE_ONE") == 0);
    
    name = reflecxx_enum_by_value(&my_enum_t_type_info, ME_TWO)->ree_name;
    assert(strcmp(name, "ME_TWO") == 0);

    name = reflecxx_enum_by_value(&my_enum_t_type_info, ME_ONE_THOUSAND)->
	ree_name;
    assert(strcmp(name, "ME_ONE_THOUSAND") == 0);

    name = reflecxx_enum_by_value(&also_my_enum_t_type_info, AME_ZERO)->
	ree_name;
    assert(strcmp(name, "AME_ZERO") == 0);

    name = reflecxx_enum_by_name(&also_my_enum_t_type_info, "AME_ZERO", -1)->
	ree_name;
    assert(strcmp(name, "AME_ZERO") == 0);
    
    name = reflecxx_enum_by_name(&also_my_enum_t_type_info, "FOO", -1)->
	ree_name;
    assert(strcmp(name, "<unknown>") == 0);
    
    return retval;
}
